<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>系统管理首页</title>
    <link rel="stylesheet" href="../css/main.css">
    <link rel="stylesheet" href="../css/bootstrap.css">
    <style>
        li{list-style: none;}
        a:visited{color: white}
    </style>
</head>
<body>
<!--顶部，主体-->
<div class="container">
    <div class="row text-center bg-black text-white">
        <div class="col-2">
            <img src="../img/2.jpg" alt="" width="50%">
        </div>
        <div class="col-8">欢迎词</div>
        <div class="col-2">
            <span>当前用户：</span>
            <span th:text="${username}"></span>
            <span><a href="/logout">退出</a></span>
        </div>
    </div>
    <div class="row" style="min-height: 400px">
        <div class="col-2 bg-black text-white pt-5">
            <li class="m-2">
                <a href="/main">管理首页</a>
            </li>
            <li class="m-2">
                <a href="/goods/goodsList">商品模块</a>
            </li>
            <li class="m-2">
                <a href="/supplier">供应商模块</a>
            </li>
            <li class="m-2">
                <a href="/user">管理用户模块</a>
            </li>
        </div>
        <div class="col-10 pt-2">
            <!--            update内容区-->
            <p>更新进货数据</p>

            <div class="form-control">
                <label for="">序号</label>
                <input type="text" name="id" id="Id" th:value="${data.id}" disabled="disabled">
            </div>
            <div class="form-control">
                <label for="">供应商名称</label>
                <input type="text" name="supplier" id="supplier" th:value="${data.supplier}">
            </div>
            <div class="form-control">
                <label for="">商品名称</label>
                <input type="text" name="name" id="name" th:value="${data.name}">
            </div>
            <div class="form-control">
                <label for="">商品种类</label>
                <input type="text" name="category" id="category" th:value="${data.category}">
            </div>
            <div class="form-control">
                <label for="">进货数量</label>
                <input type="text" name="number" id="number" th:value="${data.number}">
            </div>
            <div class="form-control">
                <label for="">进货价格</label>
                <input type="text" name="price" id="price" th:value="${data.price}">
            </div>
            <div class="form-control">
                <label for="">进货日期</label>
                <input type="text" name="time" id="time" th:value="${data.time}">
            </div>
            <div class="form-control">
                <label for="">总金额</label>
                <input type="text" name="amount" id="amount" th:value="${data.amount}">
            </div>
            <div class="form-control">
                <button class="btn btn-danger" id="btnUpdate">更新</button>
            </div>

        </div>
    </div>
    <div class="footer text-center bg-black text-white">
        @2023-2028，21106123马璐璐版权所有
    </div>
</div>
</body>
</html>
<script src="../js/jquery.min.js"></script>
<script>

    $('#btnUpdate').click(function () {
        var flag = confirm("确认提交更新？")
        if (flag == true) {
            $.post("/api/purchaseUpdateProcess", {
                "id": $('#Id').val(),"supplier":$('#supplier').val(),"name": $('#name').val(), "category": $('#category').val(),
                "number": $('#number').val(), "price": $('#price').val(),
                "time": $('#time').val(), "amount": $('#amount').val()}, function (res) {
                if (res == 1) {
                    alert("更新OK");
                    location.href = "/purchase/purchaseList"
                } else {
                    alert("更新失败");
                }
            })
        }
    })
</script>